<#if invalid?? && invalid>
<div class="alert alert-danger" role="alert">
	<strong>错误！</strong>
	无效的合同信息！
</div>
<#else>
<form class="contract-payin-form" action="${request.contextPath}/contract/pay-in" method="post">
	<input type="hidden" name="contract.id" value="${data.contract.id}" />
	<input type="hidden" name="payOut" value="${(data.payOut?string('true','false'))!''}" />
	<input type="hidden" name="gaveBack" value="${(data.gaveBack?string('true','false'))!''}" />
	<input type="hidden" name="inAccount" value="${(data.inAccount?string('true','false'))!''}">
	<div class="row">
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">
							<span class="not-null">*</span>
							收款金额
						</div>
					</div>
					<input type="text" class="form-control" name="total" placeholder="请输入支出金额">
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">
							<span class="not-null">*</span>
							收款日期
						</div>
					</div>
					<input type="text" class="form-control datetimepicker" data-format="yyyy-MM-dd" data-foot="false" data-time="${.now}" name="time" placeholder="请选择日期" readonly="readonly">
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">发票开具情况</div>
					</div>
					<select class="form-control " name="invoice">
						<option value="true">已开</option>
						<option value="false">未开</option>
					</select>
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div class="form-item-title">备注</div>
					</div>
					<textarea rows="5" class="form-control" name="remark" placeholder="最多500个汉字"></textarea>
				</div>
			</div>
		</div>
	</div>
	<hr>
	<div class="row">
		<div class="col-md-12 text-right">
			<div class="btn btn-primary btn-sm btn-submit">确定</div>
			&nbsp;
			<div class="btn btn-default btn-sm" onclick="$.suredy.closeModal();">关闭</div>
		</div>
	</div>
</form>
<script type="text/javascript">
	$(function() {
		// 初始化日期控件
		$.suredy.datetimepicker.init();

		$('form.contract-payin-form .btn-submit').on('click', function() {
			var $this = $(this);

			if ($this.hasClass('disabled'))
				return false;

			$this.addClass('disabled');

			var form = $('form.contract-payin-form');

			form.ajaxSubmit({
				dataType : "json",
				success : function(data, textStatus, jqXHR) {
					if (!data || !data.success) {
						alert(data.msg || '记录收款信息失败!');
						$this.removeClass('disabled');
						return false;
					}

					$.suredy.refreshContent('${data.contract.id}', [ '#tab2' ]);

					$.suredy.closeModal();
				},
				error : function(jqXHR, textStatus, errorThrown) {
					alert('记录收款信息失败!\n' + errorThrown);
					$this.removeClass('disabled');
					return false;
				}
			});
		});
	});
</script>
</#if>
